This document explains how to use the Data
and UIImage
global objects in the Scripting app. These classes are wrappers for iOS Data
and UIImage
objects, providing utilities for handling binary data and images.
Data
ClassThe Data
class represents a byte buffer in memory and provides utilities for creating, transforming, and encoding data.
getBytes()
Uint8Array | null
Data
instance as a Uint8Array
.toArrayBuffer()
ArrayBuffer
Data
instance to an ArrayBuffer
.toBase64String()
string
Data
instance as a Base64-encoded string.toRawString(encoding?: string)
encoding
: (optional) The string encoding format (e.g., "utf-8"
, "ascii"
).string | null
Data
instance into a raw string using the specified encoding. Defaults to "utf-8"
if no encoding is provided.fromString(string: string, encoding?: string)
string
: The input string.encoding
: (optional) The string encoding format (e.g., "utf-8"
, "ascii"
).Data | null
Data
instance from a string with the specified encoding.fromFile(filePath: string)
filePath
: The path to the file.Data | null
Data
instance.fromArrayBuffer(arrayBuffer: ArrayBuffer)
arrayBuffer
: The ArrayBuffer
to convert.Data | null
Data
instance from an ArrayBuffer
.fromBase64String(base64Encoded: string)
base64Encoded
: A Base64-encoded string.Data | null
Data
instance.fromJPEG(image: UIImage, compressionQuality?: number)
image
: The UIImage
instance to encode as JPEG.compressionQuality
: (optional) A number between 0.0
(lowest quality) and 1.0
(highest quality). Defaults to 1.0
.Data | null
UIImage
as JPEG data.fromPNG(image: UIImage)
image
: The UIImage
instance to encode as PNG.Data | null
UIImage
as PNG data.UIImage
ClassThe UIImage
class represents an image and provides methods for loading and creating image instances.
width: number
height: number
fromData(data: Data)
data
: A Data
instance containing image data.UIImage | null
UIImage
from binary image data.fromFile(filePath: string)
filePath
: The path to the image file.UIImage | null